package com.guandata.cdc.model.sink;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum SinkTableNameStrategyMode {
    PREFIX("prefix"), CUSTOM("custom");

    private final String code;

    SinkTableNameStrategyMode(String code) {
        this.code = code;
    }

    public static SinkTableNameStrategyMode fromCode(String mode) {
        if(mode == null) return CUSTOM;
        return Arrays.stream(values())
                .filter(x -> x.code.equalsIgnoreCase(mode))
                .findFirst()
                .orElse(CUSTOM);
    }
}
